package com.market.cash.ui.adapter

import android.view.View
import androidx.recyclerview.widget.RecyclerView
import com.market.cash.R
import com.market.cash.utils.adapter.CashRootRecyclerViewAdapter
import com.market.cash.utils.adapter.CashRootViewHolderHelper
import org.json.JSONObject

/**
 * CashRoot
 * @Author wwdeng
 * @CreateTime: 2024/10/18 10:55
 * @Annotation：客服
 */
class CashRootKefuAdapter(recyclerView: RecyclerView?) : CashRootRecyclerViewAdapter<JSONObject>(recyclerView, R.layout.cash_kefu_item) {

    override fun setItemChildListener(helper: CashRootViewHolderHelper, viewType: Int) {
        helper.setItemChildClickListener(R.id.btnKefuFun) //拨号、复制
    }

    override fun fillData(helper: CashRootViewHolderHelper, position: Int, model: JSONObject) {
        helper.setText(R.id.textKefuValue,model.optString("value"))
        val imgKefuIcon = helper.getImageView(R.id.imgKefuIcon)
        val type = model.optString("type")
        when(type){
            "MOBILE" -> {//电话
                helper.setText(R.id.textKefuType,mContext.getString(R.string.kefu_mobile_title))
                helper.setText(R.id.btnKefuFun,mContext.getString(R.string.kefu_dial))
                imgKefuIcon.setImageResource(R.mipmap.cash_kefu_mobile)
                helper.setVisibility(R.id.warningLayout, View.VISIBLE)
            }
            else -> {//邮箱
                helper.setText(R.id.textKefuType,mContext.getString(R.string.kefu_email_title))
                helper.setText(R.id.btnKefuFun,mContext.getString(R.string.kefu_copy))
                imgKefuIcon.setImageResource(R.mipmap.cash_kefu_email)
                helper.setVisibility(R.id.warningLayout, View.GONE)
            }
        }
    }
}